package com.example;

import com.baosight.bean.MethodInfo;
import com.baosight.bean.ParamInfo;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.body.Parameter;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class MethodNamePrinterB extends VoidVisitorAdapter<List<MethodInfo>> {
    @Override
    public void visit(MethodDeclaration md, List<MethodInfo> arg){
        super.visit(md,arg);
        String methodName=md.getNameAsString();
        String returnType=md.getType().asString();
        String commentContent=null;
        if(md.getComment().isPresent()){
            commentContent=md.getComment().get().getContent();
        }

        List<ParamInfo> paramInfoList = md.getParameters().stream().map((param ->
                new ParamInfo(param.getType().asString(), param.getNameAsString())
        )).collect(Collectors.toList());

        arg.add(new MethodInfo(commentContent,methodName,returnType,paramInfoList));

        System.out.println("Method Name Printer : "+md.getName());
        System.out.println(arg);
    }
}
